<div class="widget">
	<div class="widget-header bg-blue">
		<i class="widget-icon icon-notebook"></i> 
		<span class="widget-caption"> 学员报名 </span>
		<div class="widget-buttons">
			<a href="javascript:void(0);" onclick="handlerCancel(this);" title="关闭"
				 data-toggle="dispose" data-refresh-table="#table-customer"> <i class="fa fa-times"></i> </a> 
		</div>
	</div>
	<div class="widget-body">
		<div class="callout callout-success">
		  <p>本签约页面，仅适用于新增客源、多孩会员的未签约宝宝及会员，购买新课程时，报名签约。</p>
		  <h5>注1：未完成付款的合同，可在合同管理的待付款中查询并继续操作。</h5>
		  <h5>注2：若已签约会员（正常上课的会员）的续费签约，请通过合同管理中的续费功能进行操作。</h5>
		</div>
		
		<!-- TODO 基本信息 -->
		<div class="widget radius-bordered mgbt-xs-10">
			<div class="widget-header">
				<i class="widget-icon icon-notebook"></i> 
				<span class="widget-caption"> 基本信息 </span>
			</div>
			<div class="widget-body editor-body-sm editor-body-contract">
				<form class="form-horizontal form-editor form-editor-contract">
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="code">合同编号</label>
								<div class="col-sm-8">
									<input name="code" id="code" type="text" class="form-control">
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="createDate">签约时间</label>
								<div class="col-sm-8">
									<div class="input-group date date-selector">
										<input name="createDate" id="createDate" type="text" class="form-control"> <span class="input-group-addon">
											<span class="fa fa-calendar"></span>
										</span>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="username">课程顾问</label>
								<div class="col-sm-8">
									<input type="text" name="username" id="username" class="form-control" readonly="readonly" /> 
									<input type="hidden" name="userid" id="userid" data-default-user/>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label required" for="student">宝宝姓名</label>
								<div class="col-sm-8">
									<select name="student" id="student" class="chosen-select" data-entity="com.app.miwawa.api.esm.entity.customer.Student">
									</select>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="parent">家长姓名</label>
								<div class="col-sm-8">
									<input type="hidden" name="parents" id="parents" /> 
									<input type="text" name="parent" id="parent" class="form-control" readonly="readonly"/> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="mobile">联系方式</label>
								<div class="col-sm-8">
									<input type="text" name="mobile" id="mobile" class="form-control" readonly="readonly"/> 
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label required" for="item">购买项目</label>
								<div class="col-sm-8">
									<div class="input-group">
										<label class="radio-inline c-radio"> 
											<input type="radio" name="item" value="托班" data-show-target="#editor-panel-buyinfo-dc"/> 
											<span class="fa fa-check"></span> 托班
										</label> 
										<label class="radio-inline c-radio"> 
											<input type="radio" name="item" value="早教" data-show-target="#editor-panel-buyinfo-ee" checked="checked"/> 
											<span class="fa fa-check"></span> 早教
										</label>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-8">
							<div class="form-group">
								<label class="col-sm-2 control-label required">有效期</label>
								<div class="col-sm-10">
									<div class="input-group">
										<input name="fromDate" id="fromDate" type="text" class="form-control date-selector" required="required"> 
										<span class="input-group-addon no-border-radius">－</span>
										<input name="overDate" id="overDate" type="text" class="form-control date-selector" value="null" required="required"> 
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="invoice">开具发票</label>
								<div class="col-sm-8">
									<div class="input-group">
										<label class="radio-inline c-radio"> 
											<input type="radio" name="invoice" value="是"/> 
											<span class="fa fa-check"></span> 是&emsp;
										</label> 
										<label class="radio-inline c-radio"> 
											<input type="radio" name="invoice" value="否" checked="checked"/> 
											<span class="fa fa-check"></span> 否
										</label>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-8">
							<div class="form-group">
								<label class="col-sm-2 control-label" for="title">发票抬头</label>
								<div class="col-sm-10">
									<input type="text" name="title" id="title" class="form-control"/> 
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-8">
							<div class="form-group">
								<label class="col-sm-2 control-label" for="remark">合同备注</label>
								<div class="col-sm-10">
									<input name="remark" type="text" id="remark" class="form-control">
								</div>
							</div>
						</div>
					</div>
					<div class="widget-footer editor-footer-sm">
						<button type="button" class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="取消" onclick="handlerCancel(this);" data-refresh-table="#table-customer">
							<i class="glyphicon glyphicon-remove"></i>
						</button>
						<button type="button" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="保存" onclick="validate(this,'#editor-form-contract','.form-editor-contract');" data-submit-callback="handlerContract">
							<i class="glyphicon glyphicon-ok"></i>
						</button>
					</div>
				</form>
			</div>
		</div>
		
		<!-- TODO 购买托班 -->
		<div class="widget radius-bordered mgbt-xs-10 hidden" id="editor-panel-buyinfo-dc">
			<div class="widget-header">
				<i class="widget-icon icon-notebook"></i> 
				<span class="widget-caption"> 购买托班 </span>
			</div>
			<div class="widget-body editor-body-sm editor-body-buyinfo">
				<form class="form-horizontal form-editor form-editor-buyinfo-dc">
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="type">托班类型</label>
								<div class="col-sm-8">
									<select name="type" id="type" class="chosen-select" data-url="/miwawa/default/common/select.json" data-pcode="c_con_dc_type" data-entity="com.app.miwawa.api.system.entity.config.Codec">
									</select>
								</div>
							</div>
						</div>
						<div class="col-sm-8">
							<div class="form-group">
								<label class="col-sm-2 control-label required">起止时间</label>
								<div class="col-sm-10">
									<div class="input-group">
										<input name="fromDate" id="fromDate" type="text" class="form-control date-selector" value="null" required="required"> 
										<span class="input-group-addon no-border-radius">－</span>
										<input name="overDate" id="overDate" type="text" class="form-control date-selector" value="null"> 
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="buying">购买月数</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="buying" id="buying" class="form-control"/>
										<span class="input-group-addon">个月</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="giving">赠送月数</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="giving" id="giving" class="form-control"/>
										<span class="input-group-addon">个月</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label required" for="totals">总月数</label>
								<div class="col-sm-8">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-buyinfo-dc')" 
															data-depend='{"addition":["buying","giving"]}'
															data-target="totals"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="totals" id="totals" class="form-control" required="required"/>
										<span class="input-group-addon">个月</span>
									</div> 
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="priceUnit">单价</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="priceUnit" id="priceUnit" class="form-control" />
										<span class="input-group-addon">元/月</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="priceTotal">总价</label>
								<div class="col-sm-8">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-buyinfo-dc')" 
															data-depend='{"multiply":["priceUnit","buying"]}'
															data-target="priceTotal"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="priceTotal" id="priceTotal" class="form-control" />
										<span class="input-group-addon">元</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label required" for="useing">已用月数</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="useing" id="useing" class="form-control" value="0" required="required"/>
										<span class="input-group-addon">月数</span>
									</div> 
								</div>
							</div>
						</div>
					</div>
					<div class="widget-footer editor-footer-sm">
						<button type="button" class="btn btn-danger btn-sm" onclick="handlerCancel(this, 'editor-wrapper-open');" data-toggle="tooltip" data-placement="top" title="取消" data-refresh-table="#table-customer">
							<i class="glyphicon glyphicon-remove"></i>
						</button>
						<button type="button" class="btn btn-primary btn-sm" onclick="determine(this, '#editor-form-buyinfo', '.form-editor-buyinfo-dc');" data-toggle="tooltip" data-placement="top" title="保存">
							<i class="glyphicon glyphicon-ok"></i>
						</button>
					</div>
				</form>
			</div>
		</div>
		
		<!-- TODO 购买早教 -->
		<div class="widget radius-bordered mgbt-xs-10 hidden" id="editor-panel-buyinfo-ee">
			<div class="widget-header">
				<i class="widget-icon icon-notebook"></i> 
				<span class="widget-caption"> 购买早教 </span>
			</div>
			<div class="widget-body editor-body-sm editor-body-buying">
				<form class="form-horizontal form-editor form-editor-buyinfo-ee">
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="type">早教类型</label>
								<div class="col-sm-8">
									<select name="type" id="type" class="chosen-select" data-url="/miwawa/default/common/select.json" data-pcode="c_con_ee_type" data-entity="com.app.miwawa.api.system.entity.config.Codec">
									</select>
								</div>
							</div>
						</div>
						<div class="col-sm-8">
							<div class="form-group">
								<label class="col-sm-2 control-label required">起止时间</label>
								<div class="col-sm-10">
									<div class="input-group">
										<input name="fromDate" id="fromDate" type="text" class="form-control date-selector" value="null" required="required"> 
										<span class="input-group-addon no-border-radius">－</span>
										<input name="overDate" id="overDate" type="text" class="form-control date-selector" value="null" required="required"> 
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="buying">购买课时</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="buying" id="buying" class="form-control"/>
										<span class="input-group-addon">课时</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="giving">赠送课时</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="giving" id="giving" class="form-control"/>
										<span class="input-group-addon">课时</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label required" for="totals">总课时</label>
								<div class="col-sm-8">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-buyinfo-ee')" 
															data-depend='{"addition":["buying","giving"]}'
															data-target="totals"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="totals" id="totals" class="form-control" required="required"/>
										<span class="input-group-addon">课时</span>
									</div> 
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="priceUnit">单价</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="priceUnit" id="priceUnit" class="form-control" />
										<span class="input-group-addon">元/课时</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="priceTotal">总价</label>
								<div class="col-sm-8">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-buyinfo-ee')" 
															data-depend='{"multiply":["priceUnit","buying"]}'
															data-target="priceTotal"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="priceTotal" id="priceTotal" class="form-control" />
										<span class="input-group-addon">元</span>
									</div> 
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label required" for="useing">已用课时</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="useing" id="useing" class="form-control" value="0" required="required"/>
										<span class="input-group-addon">课时</span>
									</div> 
								</div>
							</div>
						</div>
					</div>
					<div class="widget-footer editor-footer-sm">
						<button type="button" class="btn btn-danger btn-sm" onclick="handlerCancel(this, 'editor-wrapper-open');" data-toggle="tooltip" data-placement="top" title="取消" data-refresh-table="#table-customer">
							<i class="glyphicon glyphicon-remove"></i>
						</button>
						<button type="button" class="btn btn-primary btn-sm" onclick="determine(this, '#editor-form-buyinfo', '.form-editor-buyinfo-ee');" data-toggle="tooltip" data-placement="top" title="保存">
							<i class="glyphicon glyphicon-ok"></i>
						</button>
					</div>
				</form>
			</div>
		</div>
		
		<!-- TODO 付款信息 -->
		<div class="widget radius-bordered mgbt-xs-10 hidden" id="editor-panel-payinfo">
			<div class="widget-header">
				<i class="widget-icon icon-notebook"></i> 
				<span class="widget-caption"> 付款信息 </span>
			</div>
			<div class="widget-body editor-body-sm editor-body-payinfo">
				<form class="form-horizontal form-editor form-editor-payinfo">
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="priceOrig">原价</label>
								<div class="col-sm-8">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-payinfo')" 
															data-depend='{"summation":"priceTotal"}'
															data-target="priceOrig"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="priceOrig" id="priceOrig" class="form-control" /> 
										<span class="input-group-addon">元</span>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="discount">折扣</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="discount" id="discount" class="form-control" /> 
										<span class="input-group-addon">折</span>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label" for="priceReal">实价</label>
								<div class="col-sm-9">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-payinfo')" 
															data-depend='{"percent":{"num":"discount","den":"priceOrig"}}'
															data-target="priceReal"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="priceReal" id="priceReal" class="form-control" /> 
										<span class="input-group-addon">元</span>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="payment">支付方式</label>
								<div class="col-sm-8">
									<select name="payment" id="payment" class="chosen-select" data-url="/miwawa/default/common/select.json" data-pcode="c_payment_type" data-entity="com.app.miwawa.api.system.entity.config.Codec">
									</select>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-4 control-label" for="deposit">订金</label>
								<div class="col-sm-8">
									<div class="input-group">
										<input type="text" name="deposit" id="deposit" class="form-control" /> 
										<span class="input-group-addon">元</span>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label" for="received">实收</label>
								<div class="col-sm-9">
									<div class="input-group">
										<span class="input-group-btn" data-toggle="tooltip" data-placement="top" title="计算">
											<button type="button" class="btn btn-addon" onclick="handlerCalculator(this, '.form-editor-payinfo')" 
															data-depend='{"minus":["priceReal","deposit"]}'
															data-target="received"><i class="fa fa-calculator"></i></button>
										</span>
										<input type="text" name="received" id="received" class="form-control" /> 
										<span class="input-group-addon">元</span>
									</div>
								</div>
							</div>
						</div>
					</div>
					
					<div class="widget-footer editor-footer-sm">
						<button type="button" class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="取消" onclick="handlerCancel(this, 'editor-wrapper-open');" data-refresh-table="#table-customer">
							<i class="glyphicon glyphicon-remove"></i>
						</button>
						<button type="button" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="保存"
						 				onclick="checkPayinfo(this, '#editor-form-payinfo', '.form-editor-payinfo');">
							<i class="glyphicon glyphicon-ok"></i>
						</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<!-- 提交表单 ========================================================= -->
<form id="editor-form-contract" action="/miwawa/{dbname}/contract/save" method="post" 
			name="com.app.miwawa.api.esm.entity.contract.Contract" 
			data-show-checked=":radio[name='item']" 
			data-custom-action="true">
			<input type="hidden" name="status" value="0">
			<input type="hidden" name="invalid" value="F">
</form>
<form id="editor-form-buyinfo" action="/miwawa/{dbname}/common/save" method="post" 
			name="com.app.miwawa.api.esm.entity.contract.Buyinfo" 
			data-show-target="#editor-panel-payinfo" 
			data-foreign-src="#editor-form-contract" 
			data-foreign-key="com.app.miwawa.api.esm.entity.contract.Contract">
			<input type="hidden" name="bean['status']" value="0">
			<input type="hidden" name="bean['invalid']" value="F">
			<input type="hidden" name="bean['contractId']" data-foreign-id>
</form>
<form id="editor-form-payinfo" action="/miwawa/{dbname}/common/save" method="post" 
			name="com.app.miwawa.api.esm.entity.contract.Payinfo"
			data-foreign-src="#editor-form-contract" 
			data-foreign-key="com.app.miwawa.api.esm.entity.contract.Contract">
			<input type="hidden" name="bean['status']" value="0">
			<input type="hidden" name="bean['invalid']" value="F">
			<input type="hidden" name="bean['contractId']" data-foreign-id>
</form>

<script type="text/javascript">
<!--
	var customer;
	var $moment;
	
	jQuery(function() {
		customer = jQuery("#table-customer").data("selectedRow");
		loaderCustomer();
	});	
	
	// 载入客户基本信息
	function loaderCustomer(){
		jQuery("#userid",".form-editor-contract").val(userid);
		jQuery("#username",".form-editor-contract").val(username);
		jQuery("#customerId,:hidden[name='customerId']").val(customer.customerid);
		
		jQuery("#mobile",".form-editor-contract").val(customer.mobile);
		jQuery("#parents",".form-editor-contract").val(customer.parentid);
		jQuery("#parent",".form-editor-contract").val(customer.parent);
		
		require(['jquery.plugin.form','jquery.bootstrap.editable'],function(form, editable){
			form.datepicker(".date-selector");
			form.tooltip("[data-toggle='tooltip']");
			
			form.chosen("#student").select("#student",{querys:{"customerId_EQ":customer.customerid}},function(chosen){
				jQuery("option[value='"+customer.studentid+"']",chosen).attr("selected","selected").trigger('chosen:updated');
			});
			form.chosen("#payment").select("#payment");
			form.chosen(jQuery("#type",".form-editor-buyinfo-dc")).select(jQuery("#type",".form-editor-buyinfo-dc"));
			form.chosen(jQuery("#type",".form-editor-buyinfo-ee")).select(jQuery("#type",".form-editor-buyinfo-ee"));
			
			editable.register("[data-editable]");
		});
	}
	
	// 保存合同基本信息后回调
	function handlerContract(options){
		if(options.id){
			jQuery("#fromDate","#editor-panel-buyinfo-dc").val(options.fromDate);
			jQuery("#overDate","#editor-panel-buyinfo-dc").val(options.overDate);
			jQuery("#fromDate","#editor-panel-buyinfo-ee").val(options.fromDate);
			jQuery("#overDate","#editor-panel-buyinfo-ee").val(options.overDate);
		}else{
			jQuery.message.alert("合同信息保存失败，合同编号不符合系统标准，请手工填写合同编码。（关闭本页面，重新报名）");
		}
	}
	
	// 表单自动计算按钮事件
	function handlerCalculator(trigger, _form){
		var depend = jQuery(trigger).data("depend");
		var target = jQuery(trigger).data("target");
		var number = 0;
		
		if(depend.multiply){
			var price = 1;
			for(var index in depend.multiply){
				price *= new Number(jQuery("[name='"+depend.multiply[index]+"']", _form).val());
			}
			number = price;
		}else if(depend.addition){
			var total = 0;
			for(var index in depend.addition){
				total += new Number(jQuery("[name='"+depend.addition[index]+"']", _form).val());
			}
			number = total;
		}else if(depend.summation){
			jQuery("[name='"+depend.summation+"']").each(function(i,n){
				number += new Number(jQuery(n).val());
			});
		}else if(depend.percent){
			var discount = jQuery("[name='"+depend.percent.num+"']", _form).val();
			var priceOrig = jQuery("[name='"+depend.percent.den+"']", _form).val();
			if(discount){
				number = new Number(priceOrig)*new Number(discount)/10;
			}else{
				number = new Number(priceOrig);
			}
		}else if(depend.minus){
			for(var index in depend.minus){
				number = Math.abs(number) - jQuery("[name='"+depend.minus[index]+"']", _form).val();
			}
		}
		jQuery("[name='"+target+"']", _form).val(number);
	}

	// 更新客户状态
	function updateCustomer(){
		jQuery.ajaxsend({
			url:"/miwawa/{dbname}/customer/update".replace("{dbname}", dbname),
			data:{ "id":customer.customerid, "status":"member" }
		});
	}
	
	//判断是否有执行中的同类型合同
	function validate(button,table,form){
		jQuery.ajax({
			url : "/miwawa/{dbname}/common/search.json".replace("{dbname}",dbname),
		  type : "POST",
		  dataType : "json",
		  data : {
		       		"entityClass" : "com.app.miwawa.api.esm.entity.view.ContractView",
		          "and[0][operator]": "EQ",
		          "and[0][fieldName]": "studentid",					
		          "and[0][fieldValue]": jQuery("#student").val(),						
		          "and[1][operator]": "EQ",
		          "and[1][fieldName]": "item",					
		          "and[1][fieldValue]": jQuery('input:radio[name="item"]:checked').val(),						
		          "and[2][operator]": "EQ",
		          "and[2][fieldName]": "status",			
		          "and[2][fieldValue]": "0"
		  },
		  async : false,
		  success : function(data) {
		    var dataList = data.rows;
		    if(dataList.length > 0){
		    	jQuery.message.alert("该学员此类型正在执行的合同已存在，请通过合同管理中的续费功能进行签约操作！");
		    	return;
		    }else{
		    	if(jQuery("#fromDate",".form-editor-contract").val() == "" || jQuery("#overDate",".form-editor-contract").val() == ""){
		    		jQuery.message.alert("请填写合同有效期");
		    		return;		    	
		    	}else{
			    	var fromDate = $moment(jQuery("#fromDate",".form-editor-contract").val()).format("YYYY-MM-DD")+" 01:00:00";
			    	var overDate = $moment(jQuery("#overDate",".form-editor-contract").val()).format("YYYY-MM-DD")+" 02:00:00";
			    	var nowDate = $moment().format("YYYY-MM-DD")+" 00:00:00";
			    	if($moment(fromDate).isAfter($moment(overDate))){
			    		jQuery.message.alert("合同结束时间不能早于起始时间");
			    		return;
			    	}else if($moment(nowDate).isAfter($moment(overDate))){
			    		jQuery.message.alert("合同结束时间不能早于当前时间");
			    		return;
			    	}else{
				    	handlerSubmit(button, table, form);
			    	}
		    	}
		   	} 
		  }
		});
	}
	
	
	//上课起始结束时间的判断,总课时,总月数,总价必填拦截
	function determine(button,table,form){
		var fromDate = $moment(jQuery("#fromDate",form).val()).format("YYYY-MM-DD")+" 01:00:00";
   	var overDate = $moment(jQuery("#overDate",form).val()).format("YYYY-MM-DD")+" 02:00:00";
   	var nowDate = $moment().format("YYYY-MM-DD")+" 00:00:00";
   	if($moment(fromDate).isAfter($moment(overDate))){
   		jQuery.message.alert("上课结束时间不能早于上课开始时间");
   		return;
   	}else if($moment(nowDate).isAfter($moment(overDate))){
   		jQuery.message.alert("上课结束时间不能早于当前时间");
   		return;
   	}else if(jQuery("#totals",form).val() == ""){
   		if(form == ".form-editor-buyinfo-ee"){
   			jQuery.message.alert("请填写总课时");
   		}else{
   			jQuery.message.alert("请填写总月数");
   		}
   		return;
   	}else if(jQuery("#priceTotal",form).val() == ""){
   		jQuery.message.alert("请填写总价");
   		return;
   	}else{
    	handlerSubmit(button, table, form);
   	}
	}
	
	//付款信息的检查
	function checkPayinfo(button,table,form){
		if(jQuery("#priceOrig",form).val() == ""){
	   	jQuery.message.alert("请填写原价！");
	   	return;
	  }else if(jQuery("#priceReal",form).val() == ""){
	   	jQuery.message.alert("请填写实价！");
	   	return;
	  }else if(jQuery("#received",form).val() == ""){
		  jQuery.message.alert("请填写实收！");	
	   	return;	   
	  }else{
		  updateCustomer();
	    handlerSubmit(button, table, form);
	  }
	}
//-->
</script>